﻿#ifndef MUSICSLIDER_H
#define MUSICSLIDER_H

#include <QWidget>
#include <QMouseEvent>

namespace Ui {
class MusicSlider;
}

class MusicSlider : public QWidget
{
    Q_OBJECT

public:
    explicit MusicSlider(QWidget *parent = nullptr);
    ~MusicSlider();

    // 对滑动条进行移动
    void moveSlider();

    // 设置步长,跟随音乐,进度条增加
    void setStep(float ration);

signals:
    void setMusicSliderPosition(float ration); // 进度条和播放音乐时间同步

protected:
    // 重写鼠标按下, 释放, 移动操作
    void mousePressEvent(QMouseEvent* event);
    void mouseReleaseEvent(QMouseEvent* event);
    void mouseMoveEvent(QMouseEvent* event);

private:
    Ui::MusicSlider *ui;

    int currentPos; // 滑动条当前位置
    int maxWidth;   // 滑动条最大宽度
};

#endif // MUSICSLIDER_H
